/*
This file is part of MMM.

MMM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

MMM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with MMM.  If not, see <http://www.gnu.org/licenses/>.
*
* @package    MMM
* @author     Andre Meixner
* @copyright  2018 High Performance Humanoid Technologies (H2T), Karlsruhe, Germany
*
*/

#ifndef __MMM_INTERPOLATABLESENSORMEASUREMENT_H_
#define __MMM_INTERPOLATABLESENSORMEASUREMENT_H_

#include <boost/shared_ptr.hpp>
#include "SensorMeasurement.h"

namespace MMM
{

template <typename M>
/*! \brief Template for interpolatable sensor measurements */
class MMM_IMPORT_EXPORT InterpolatableSensorMeasurement : public SensorMeasurement
{
protected:
    InterpolatableSensorMeasurement(float timestep, SensorMeasurementType type = SensorMeasurementType::MEASURED) :
        SensorMeasurement(timestep, type)
    {
    }

    virtual boost::shared_ptr<M> interpolate(boost::shared_ptr<M> other, float timestep, SensorMeasurementType type) = 0;

public:
    boost::shared_ptr<M> interpolateMeasurement(boost::shared_ptr<M> other, float timestep) {
        SensorMeasurementType type = SensorMeasurementType::INTERPOLATED;
        if (this->type == SensorMeasurementType::EXTENDED || other->type == SensorMeasurementType::EXTENDED)
            type = SensorMeasurementType::EXTENDED;
        return interpolate(other, timestep, type);
    }
};

}

#endif // __MMM_INTERPOLATABLESENSORMEASUREMENT_H_
